<template>
  <div class="BookingRecord-box">
    <div class="table-box">
      <el-table
      :data="bookingRecordList"
      style="width: 100%;"
      :default-sort = "{prop: 'date', order: 'descending'}"
      >
        <el-table-column
          prop="id"
          label="记录编号"
          width="300">
        </el-table-column>
        <el-table-column label="时间信息">
          <el-table-column
            prop="date"
            label="日期"
            sortable
            width="150">
          </el-table-column>
          <el-table-column
            prop="duration"
            label="节次"
            width="180">
          </el-table-column>
        </el-table-column>
        <el-table-column
          prop="roomId"
          label="教室编号"
          sortable
          width="180">
        </el-table-column>
        <el-table-column
          prop="userId"
          label="预约用户"
          width="180">
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination-box">
            <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="param.pageNo"
            :page-sizes="[5, 10, 15]"
            :page-size="5"
            layout="sizes, prev, pager, next, jumper"
            >

            </el-pagination>
        </div>		
  </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    name:'BookingRecord',
    data() {
      return {
        param:{
          pageSize:5,
          pageNo:1
        }
      }
    },
    methods: {
      handleSizeChange(val) {
        this.param.pageNo=1;
        this.param.pageSize=val;
        this.getBookingRoomRecordList();
      },
      handleCurrentChange(val) {
        this.param.pageNo=val;
        this.getBookingRoomRecordList();
      },
      getBookingRoomRecordList(){
        this.$store.dispatch("bookingRecord/getBookingRecordList",this.param)
      }
    },
    computed:{
      ...mapState('bookingRecord',['bookingRecordList'])
    },
    mounted(){
      this.$store.dispatch("bookingRecord/getBookingRecordList",this.param)
    }
}
</script>

<style lang="css" scoped>
  .BookingRecord-box{
    position:inherit;
    top:0;
    height:100%;
    left:0;
    width:100%;
    overflow: auto;
  }
  .table-box{
    position: inherit;
    margin-left: 10%;
    top: 30px;
    width: 80%;
    height: 80%;
    overflow: auto;
  }
  .pagination-box{
    position: inherit;
    top: 90%;
    width:100%;
    text-align: center;
  }
</style>